﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" MaintainScrollPositionOnPostback="true" %>

<asp:content id="Content1" contentplaceholderid="HeadContent" runat="Server">
    <asp:panel id="AuthenticatedHeaderPanel" runat="server">
        <ul id="user">
            <li>
                <asp:loginstatus id="LoginStatus1" runat="server" logoutaction="Redirect" logoutpageurl="~/Login.aspx" />
            </li>
        </ul>
        <div id="header-inner">
            <div class="textt">
                <h4>
                    <asp:label runat="server" id="WelcomeBackMessage"></asp:label>
                    <asp:label id="lblMessage" runat="server" enableviewstate="false" />
                </h4>
            </div>
        </div>
    </asp:panel>
</asp:content>
<asp:content id="Content2" contentplaceholderid="Menu" runat="Server">
    <div id="left">
        <div id="navigation">
            <asp:panel runat="server" id="AuthenticatedMenuPanel" width="200px">
                <div id="menu-header">
                    <div class="menutext">
                        <asp:label runat="server" text="Menu" />
                    </div>
                </div>
                <asp:menu id="Menu1" runat="server" staticdisplaylevels="3" backcolor="White" dynamichoverstyle-borderstyle="NotSet" width="200px">
                   <items>                
                    <asp:MenuItem Text="Home" Value="Home" navigateurl="Default.aspx">
                      <%--<asp:MenuItem Text="New Document" Value="New Document" navigateurl="AddDocument.aspx"/>--%>
                    </asp:MenuItem>

                    <asp:MenuItem Text="Users" Value="My_Users" navigateurl="MyUsers.aspx">
                      <%--<asp:MenuItem Text="New User" Value="New_User" navigateurl="AddUser.aspx">--%>
                    </asp:MenuItem>

                    <asp:MenuItem Text="Companies" Value="Companies" navigateurl="MyCompanies.aspx">
                      <%--<asp:MenuItem Text="New Company" Value="New_Company" navigateurl="AddCompany.aspx"/>--%>
                    </asp:MenuItem>

                    <asp:MenuItem Text="Clients" Value="Clients" navigateurl="MyClients.aspx">
                      <%--<asp:MenuItem Text="New Client" Value="New_Client" navigateurl="AddClient.aspx"/>--%>                   
                    </asp:MenuItem>
                  </items>
                </asp:menu>
            </asp:panel>
        </div>
    </div>
</asp:content>
<asp:content id="Content3" contentplaceholderid="MainContent" runat="Server">
    <div id="right">
        <asp:panel runat="server" id="AuthenticatedMessagePanel">
        <asp:scriptmanager id="ScriptManager1" runat="server" />
            <div class="box">
                <div class="title">
                    <h6>
                        <asp:label runat="server" text="My documents"></asp:label>
                    </h6>
                </div>
                <div class="lists">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">                  
                    <ContentTemplate>
                    <asp:Label id="status" runat="server" Text="" Visible="true"/>
                    <div id="search" runat="server">
                        <div id="searchForm">
                            <div class="searchSection">
                                <ul>
                                    <li style="padding: 1px 0 !important;">
                                        <asp:Label id="lbl" runat="server" Text="Search document"/>
                                        <asp:TextBox ID="tb_search" runat="server" ToolTip="Enter document number!" CssClass="glowTextbox"/>
                                    </li>
                                    <li>
                                        <asp:Button ID="bt_search" runat="server" OnClick="bt_Search_Click" CssClass="BlueBtn" Text="Search"/>
                                    </li>
                                </ul>
                            </div>
                            <hr class="searchSeparator">
                            <div class="searchSection">
                                <ul>
                                    <li>
                                        <asp:Label id="Label1" runat="server" Text="Status:"/>
                                    </li>
                                    <li>                                    
                                        <asp:Button id="bt_active" runat="server" onclick="bt_active_Click" Text="Active" CssClass="ButtonAsLink"/>
                                        |
                                    </li>
                                    <li>
                                        <asp:Button id="bt_deleted" runat="server" onclick="bt_deleted_Click" Text="Deleted" CssClass="ButtonAsLink"/>
                                        |
                                    </li>
                                    <li>
                                        <asp:Button id="bt_all" runat="server" onclick="bt_all_Click" Text="All" CssClass="ButtonAsLink"/>                                    
                                    </li>
                                </ul>
                            </div>                            
                        </div>
                    </div>
                    <asp:ListView ID="My_documents_list" runat="server" OnPagePropertiesChanging="My_documents_list_PagePropertiesChanging"
                        OnItemCommand="My_documents_list_ItemCommand" OnItemDataBound="My_documents_list_ItemDataBound"
                        OnItemDeleting="My_documents_list_ItemDeleting" OnItemEditing="My_document_list_Editing">
                        <LayoutTemplate>                        
                            <table id="gradient-style">
                                <thead>
                                    <tr>
                                        <th>
                                        </th>
                                        <th>Number
                                            <asp:ImageButton ID="doc_num" CommandName="doc_num" ImageUrl="~/Images/asc.png" runat="server" />
                                            <asp:ImageButton ID="doc_num1" CommandName="doc_num_desc" ImageUrl="~/Images/desc.png" runat="server" />
                                        </th>
                                        <th>Date
                                            <asp:ImageButton ID="doc_date" CommandName="doc_date" ImageUrl="~/Images/asc.png" runat="server" />
                                            <asp:ImageButton ID="doc_date1" CommandName="doc_date_desc" ImageUrl="~/Images/desc.png" runat="server" />
                                        </th>
                                        <th>Payment date</th>
                                        <th>Company</th>
                                        <th>Client</th>
                                        <th>Type</th>
                                        <th>Payment type</th>
                                        <th>Status </th>
                                        <th colspan="3">Options</th>
                                    </tr>
                                </thead>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                                <tfoot>
                                    <tr>
                                        <th style="text-align: right" colspan="12">
                                            <asp:DataPager ID="My_documents_list_Page" runat="server" PagedControlID="My_documents_list" PageSize="5">
                                                <Fields>
                                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                    <asp:NumericPagerField />
                                                    <asp:TemplatePagerField>
                                                        <PagerTemplate>
                                                            Page
                                                            <asp:Label runat="server" ID="labelCurrentPage" Text="  <%  #  Container.TotalRowCount > 0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0  %>  " />
                                                            /
                                                            <asp:Label runat="server" ID="labelTotalPages" Text="  <%  #   Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize)  %>  " />
                                                        </PagerTemplate>
                                                    </asp:TemplatePagerField>
                                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                </Fields>
                                            </asp:DataPager>
                                        </th>
                                    </tr>
                                </tfoot>
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr runat="server" id="_itemrow">
                                <td id="my_docID" runat="server">
                                    <asp:Label ID="my_doc_IDLabel" runat="server" Text='<%# Eval("id") %>' />
                                </td>
                                <td>
                                    <asp:CheckBox ID="check_delete_doc" runat="server" />
                                </td>
                                <td>
                                    <asp:LinkButton ID="my_document_numberLabel" runat="server" Text='<%# Eval("document_number") %>' CommandName="Invoice" />
                                </td>
                                <td id="my_doc_num" runat="server">
                                    <asp:Label ID="my_document_numLabel" runat="server" Text='<%# Eval("document_number") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_document_dateLabel" runat="server" Text='<%# Eval("document_date","{0:yyyy.MM.dd}") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_document_payment_dateLabel" runat="server" Text='<%# Eval("document_payment_date","{0:yyyy.MM.dd}") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_company_issued_byLabel" runat="server" Text='<%# Eval("company_issued_by") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_company_issued_toLabel" runat="server" Text='<%# Eval("client_issued_to") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_id_document_typeLabel" runat="server" Text='<%# Eval("document_type") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_id_payment_typeLabel" runat="server" Text='<%# Eval("payment_type") %>' />
                                </td>
                                <td id="my_idL" runat="server">
                                    <asp:Label ID="my_id_issued_userLabel" runat="server" Text='<%# Eval("id_issued_by_user") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="my_statuss" runat="server" Text='<%# Eval("status") %>' />
                                </td>
                                <td>
                                    <asp:ImageButton ID="lnkEdit" runat="server" CommandName="Edit" ImageUrl="~/Images/file_edit.png" ToolTip="Edit" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="lnkDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/file_delete.png" ToolTip="Delete" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="lnkShare" runat="server" CommandName="Share" ImageUrl="~/Images/file_share.png" ToolTip="Share" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>
                            <asp:Panel ID="PopupShare" runat="server" CssClass="popupBody" style="display: none">
                                <div class="popupContainer" style="width: 400px">
                                    <div class="popupTitlebar">
                                        <div class="titlebarLeft">
                                            <asp:Literal ID="_titleLiteral" runat="server" Text="Your users!" />
                                        </div>
                                        <div class="titlebarRight" onclick="OnCancel();"></div>
                                    </div>
                                    <div class="popupBody">
                                        <asp:Label ID="share_document_number" runat="server" />
                                        <asp:Label ID="share_document_ID" runat="server" />
                                        <asp:Label ID="share_document_user_ID" runat="server" Visible="false"/>

                                        <asp:UpdatePanel ID="Share_list_Update_panel" runat="server" >
                                            <ContentTemplate>                                            
                                                <asp:ListView ID="My_users_share_list" runat="server" OnItemDataBound="My_users_share_list_ItemDataBound" OnPagePropertiesChanging="My_users_share_list_PagePropertiesChanging">
                                                    <LayoutTemplate>
                                                        <table id="gradient-style" class="tab" style="width: 100%">
                                                            <thead>
                                                                <tr>
                                                                    <th>Name</th>
                                                                    <th>Secondname</th>
                                                                    <th>Email</th>
                                                                    <th>Share</th>
                                                                </tr>
                                                            </thead>
                                                            <tr id="itemPlaceholder" runat="server">
                                                            </tr>
                                                            <tfoot>
                                                                <tr>
                                                                    <th style="text-align: right" colspan="9">
                                                                        <asp:DataPager ID="My_users_share_list_Page" runat="server" PagedControlID="My_users_share_list" PageSize="1">
                                                                            <Fields>
                                                                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                                                <asp:NumericPagerField />
                                                                                <asp:TemplatePagerField>
                                                                                    <PagerTemplate>
                                                                                        Page
                                                                                        <asp:Label runat="server" ID="labelCurrentPage1" Text="  <%  #  Container.TotalRowCount > 0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0  %>  " />
                                                                                        /
                                                                                        <asp:Label runat="server" ID="labelTotalPages1" Text="  <%  #   Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize)  %>  " />
                                                                                    </PagerTemplate>
                                                                                </asp:TemplatePagerField>
                                                                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                                            </Fields>
                                                                        </asp:DataPager>
                                                                    </th>
                                                                </tr>
                                                            </tfoot>
                                                        </table>
                                                    </LayoutTemplate>
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td id="idL" runat="server">
                                                                <asp:Label ID="idLabel" runat="server" Text='<%# Eval("_id") %>' />
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("_name") %>' />
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="secondnameLabel" runat="server" Text='<%# Eval("_secondname") %>' />
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="emailLabel" runat="server" Text='<%# Eval("_email") %>' />
                                                            </td>
                                                            <td>
                                                                <asp:CheckBox ID="check_share" runat="server" />
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                </asp:ListView>
                                                <div style="text-align:center;">
                                                    <asp:Label ID="share_modal_message" runat="server" Text="&nbsp" style="color: Green; font-size:0.8em; font-weight:bold;"/>
                                                </div>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>                                     

                                        <div id="content" style="background: none; min-height: 0px;" runat="server">
                                            <div class="box" style="min-height: 0px;">
                                                <div class="message-notice" id="message3" runat="server">
                                                    <div class="image">
                                                        <img height="32" alt="Notice" src="Images/notice.png">
                                                    </div>
                                                    <div class="text">
                                                        <h4>You have no users!</h4>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="buttons">                                        
                                        <button class="BlueBtn" id="bt_share" runat="server" onserverclick="bt_share_Click" style="width: auto;"><span class="label">Save</span></button>
                                        <button class="CancelBtn" id="bt_Cancel" runat="server"  onserverclick="bt_share_cancel_Click" style="width: auto;"><span class="label">Cancel</span></button>
                                    </div>
                                </div>

                            </asp:Panel>
                            <asp:hiddenfield id="HiddenField" runat="server" />
                            <ajaxToolkit:ModalPopupExtender ID="Modal_PopupShare" runat="server" TargetControlID="HiddenField" PopupControlID="PopupShare" CancelControlID="bt_Cancel" BackgroundCssClass="modalPopupBackground" />

                            <asp:Panel ID="PopupDelete" runat="server" CssClass="popupBody" style="display: none">
                                <div class="popupContainer" style="width: auto; min-width: 400px">
                                    <div class="popupTitlebar">
                                        <div class="titlebarLeft">
                                            <asp:Literal ID="Literal1" runat="server" Text="Delete!" />
                                        </div>
                                        <div class="titlebarRight" onclick="OnCancelDelete();"></div>
                                    </div>
                                    <div class="popupBody">
                                        <asp:Label ID="IDdoc" runat="server" Visible="false"/>
                                        <div id="content" style="background: none; min-height: 0px;">
                                            <div class="box" style="min-height: 0px;">
                                                <div class="message-notice" id="message4" runat="server">
                                                    <div class="image">
                                                        <img height="32" alt="Notice" src="Images/notice.png">
                                                    </div>
                                                    <div class="text">
                                                        <h4 id = "delete_message_text" runat="server"></h4>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="buttons">
                                        <button class="BlueBtn" id="bt_delete_to_all" runat="server" onserverclick="bt_delete_to_all_Click" style="width: auto;"><span class="label">To All</span></button>
                                        <button class="BlueBtn" id="bt_delete_me" runat="server" onserverclick="bt_delete_me_Click" style="width: auto;"><span id="delete_me" runat="server" class="label">Only Me</span></button>
                                        <button class="CancelBtn" id="bt_Cancel_delete" runat="server" onserverclick="bt_delete_cancel_Click" style="width: auto;"><span class="label">Cancel</span></button>
                                    </div>
                                </div>
                            </asp:Panel>
                            <asp:hiddenfield id="HiddenField1" runat="server" />
                            <ajaxToolkit:ModalPopupExtender ID="Modal_Popup_Delete" runat="server" Drag="true" PopupDragHandleControlID="PopupDelete" TargetControlID="HiddenField1" PopupControlID="PopupDelete" CancelControlID="bt_Cancel_delete" BackgroundCssClass="modalPopupBackground" />
                            
                            <%--Add new document Popup width: 830px; height:860px;--%>
                            <asp:Panel ID="Add_document" runat="server" CssClass="popupBody" style="display: none">
                                <div class="popupContainer" style="width: 900px; height:500px;">
                                    <div class="popupTitlebar">
                                        <div class="titlebarLeft">
                                            <asp:Literal ID="lit_add_document" runat="server" Text="Add new document!" />
                                        </div>
                                        <div class="titlebarRight" onclick="OnCancel();"></div>
                                    </div>
                                    <div class="popupBody">
                                        <asp:UpdatePanel ID="Update_AddDocument" runat="server" UpdateMode="Conditional" >
                                           <ContentTemplate>
                                        <asp:Label ID="lbl_user_id" runat="server" Text=""/>
                                        <asp:Label ID="lbl_document_id" runat=server Text=""/>
                                        <asp:Label ID="lbl_document_edit" runat=server Text=""/>
                                        <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" CssClass="tab" ActiveTabIndex="0">
                                            <ajaxToolkit:TabPanel ID="tab_document" HeaderText="Add document" runat="server">
                                                <ContentTemplate>                                                     
                                                    <table style="color: #292929; font-family: Arial,Helvetica,sans-serif; font-size: 0.9em; line-height: 1.4em; padding: 5px 7px; width:100%; text-align:right; border-collapse: collapse; border-spacing: 0;">
                                                        <tbody>
<%--                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">User: </th>
                                                                <th colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; padding-top:9px;">
                                                                    <asp:Label ID="lbl_user" runat="server" Text="" Height="28px"/>
                                                                </th>
                                                            </tr>--%>
                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Document type:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_doc_type" runat="server" AutoPostBack="True" InitialValue="--Select--" onselectedindexchanged="Drop_doc_type_SelectedIndexChanged" CssClass="glowTextbox" Height="28px"/>
                                                                </td>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Document number:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:TextBox Enabled="False" BorderStyle="None" BackColor="#FFFFFF" ID="tb_doc_number" runat="server" Font-Bold="True" Height="28px" Width="100px"/>
                                                                    <asp:RequiredFieldValidator ID="doc_number_Validator" runat="server" ControlToValidate="tb_doc_number" ErrorMessage=" " SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                                    <asp:Image ID="Image15" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select document type to generate document number!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                    <asp:TextBox Enabled="False" BorderStyle="None" BackColor="#FFFFFF" ID="tb_doc_number_OLD" runat="server" Font-Bold="True" Height="28px" Width="150px"/>
                                                                </td>
                                                            </tr>

                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Document date:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:TextBox ID="tb_doc_date" runat="server" CssClass="glowTextbox"/>
                                                                    <asp:Image ID="Image1" runat="server" ImageUrl="Images/date_picker.png" ImageAlign="AbsMiddle" />
                                                                    <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="tb_doc_date" PopupButtonID="Image1" Format="yyyy.MM.dd"/>
                                                                    <asp:RequiredFieldValidator ID="doc_date_Validator" runat="server" ControlToValidate="tb_doc_date" ErrorMessage=" " SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                                    <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select document date!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Payment date:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:TextBox ID="tb_doc_pay_date" runat="server" CssClass="glowTextbox"/>
                                                                    <asp:Image ID="Image2" runat="server" ImageUrl="Images/date_picker.png" ImageAlign="AbsMiddle"/>
                                                                    <ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="tb_doc_pay_date" PopupButtonID="Image2" Format="yyyy.MM.dd"/>
                                                                    <asp:RequiredFieldValidator ID="doc_pay_date_Validator" runat="server" ControlToValidate="tb_doc_pay_date" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                                    <asp:Image ID="Image4" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select document payment date!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                            </tr>
                                                                                                                                                                             
                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Company from:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_company_from" runat="server" OnSelectedIndexChanged="Drop_company_from_SelectedIndexChanged" AutoPostBack="True" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="company_from_Validator" runat="server" ControlToValidate="Drop_company_from" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select company!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Client to:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_client_to" runat="server" OnSelectedIndexChanged="Drop_client_to_SelectedIndexChanged" AutoPostBack="True" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="client_to_Validator" runat="server" ControlToValidate="Drop_client_to" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image9" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select client!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th rowspan="3" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; width:120px;"></th>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Address:</th>
                                                                <td style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_address_company_from" runat="server" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="Drop_address_company_from_Validator" runat="server" ControlToValidate="Drop_ADDRESS_company_from" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image6" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select company address!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                                
                                                                <th rowspan="3" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; width:150px;"></th>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Address:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_address_client_to" runat="server" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="address_client_to_Validator" runat="server" ControlToValidate="Drop_ADDRESS_client_to" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image10" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select client address!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;" >Bank:</th>
                                                                <td style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_BANK_company_from" runat="server" OnSelectedIndexChanged="Drop_company_from_bank_SelectedIndexChanged" AutoPostBack="True" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="Drop_BANK_company_from_Validator" runat="server" ControlToValidate="Drop_BANK_company_from" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image7" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select company bank!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>

                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Bank:</th>
                                                                <td style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_BANK_client_to" runat="server" OnSelectedIndexChanged="Drop_client_to_bank_SelectedIndexChanged" AutoPostBack="True" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="Drop_BANK_client_to_Validator" runat="server" ControlToValidate="Drop_BANK_client_to" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image11" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select client bank!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Account: </th>
                                                                <td style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_ACCOUNT_company_from" runat="server" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="Drop_account_company_from_Validator" runat="server" ControlToValidate="Drop_ACCOUNT_company_from" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image8" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select company account!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>

                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Account: </th>
                                                                <td style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_ACCOUNT_client_to" runat="server" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="Drop_ACCOUNT_client_to_Validator" runat="server" ControlToValidate="Drop_ACCOUNT_client_to" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image12" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select client account!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Payment type:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:DropDownList ID="Drop_pay_type" runat="server" CssClass="glowTextbox" Height="28px"/>
                                                                    <asp:RequiredFieldValidator ID="pay_type_Validator" runat="server" ControlToValidate="Drop_pay_type" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add" InitialValue="--Select--">
                                                                    <asp:Image ID="Image13" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select payment type!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                                <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: right;">Place of delivery:</th>
                                                                <td colspan="2" style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; min-width: 210px;">
                                                                    <asp:TextBox ID="tb_delivery_place" runat="server" TextMode="MultiLine" CssClass="glowTextbox" Height="56px"/>
                                                                    <asp:RequiredFieldValidator ID="delivery_place_Validator" runat="server" ControlToValidate="tb_delivery_place" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                                    <asp:Image ID="Image14" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Place of delivery can't be blank!" ImageAlign="AbsMiddle"/></asp:RequiredFieldValidator>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                
                                                            </tr>                                                            
                                                        </tbody>
                                                    </table>
                                                    <div style="text-align:center; padding:10px;">
                                                        <asp:Label ID="modal_message_document" runat="server" Text="&nbsp" style="font-size:0.9em; font-weight:bold;"/>
                                                    </div>
                                                    <div class="buttons">
                                                        <asp:button CssClass="BlueBtn" id="bt_add_company" runat="server" OnClick="bt_add_document_Click" causesvalidation="true"  validationgroup="add" Text="Save"></asp:button>
                                                        <asp:button CssClass="CancelBtn" id="bt_Cancel1" runat="server" OnClick="bt_add_document_cancel_Click" causesvalidation="false" Text="Cancel"></asp:button>                                            
                                                    </div>
                                                </ContentTemplate>
                                            </ajaxToolkit:TabPanel>
                                            <ajaxToolkit:TabPanel ID="tab_document_articles" HeaderText="Add document articles" runat="server">
                                                <ContentTemplate>
                                                     <div class="lists">                                                     
<%--                                                     <asp:Label ID="Label2" runat=server />                                                     
                                                        <div class="box" style="min-height: 0px;">
                                                            <div class="message-notice" id="message_no_article" runat="server">
                                                                <div class="image">
                                                                    <img height="32" alt="Notice" src="Images/notice.png">
                                                                </div>
                                                                <div class="text">
                                                                    <h4>Document have no articles!</h4>
                                                                </div>
                                                            </div>
                                                        </div>--%>
                                                     
                                                     <asp:ListView ID="article_list" runat="server" onitemcommand="article_list_ItemCommand" onitemdatabound="article_list_ItemDataBound" InsertItemPosition="LastItem" onitemediting="article_list_ItemEditing">
                                                         <LayoutTemplate>
                                                            <table id="gradient-style">
                                                                  <thead>
                                                                      <tr>
                                                                        <th> Name</th>
                                                                        <th> Count</th>
                                                                        <th> Price without VAT</th>
                                                                        <th> Sum without VAT</th>
                                                                        <th colspan="6"> Options</th>
                                                                      </tr>
                                                                   </thead>                          
                                                                  <tr ID="itemPlaceholder" runat="server"></tr>                       
                                                                   <tfoot>
                                                                    <tr>
                                                                        <th style="text-align:right" colspan="8">
                                                                        </th>
                                                                    </tr>
                                                                   </tfoot>
                                                            </table>
                                                        </LayoutTemplate>
                                                        <AlternatingItemTemplate>
                                                            <tr>
                                                                <td id="article_ID" runat="server">
                                                                    <asp:Label ID="id_articleLabel" runat="server" Text='<%# Eval("_id") %>' />
                                                                </td>
                                                                <td id="document_ID" runat="server">
                                                                    <asp:Label ID="id_documentLabel" runat="server" Text='<%# Eval("_id_document") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("_article_name") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="countLabel" runat="server" Text='<%# Eval("_article_count") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="priceLabel" runat="server" Text='<%# Eval("_article_price") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="sumLabel" runat="server" Text='<%# Eval("_article_sum") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                                                                </td>
                                                                <td>
                                                                    <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                                                                </td>
                                                            </tr>
                                                        </AlternatingItemTemplate>
                                                        <ItemTemplate>
                                                            <tr>
                                                                <td id="article_ID" runat="server">
                                                                    <asp:Label ID="id_articleLabel" runat="server" Text='<%# Eval("_id") %>' />
                                                                </td>
                                                                <td id="document_ID" runat="server">
                                                                    <asp:Label ID="id_documentLabel" runat="server" Text='<%# Eval("_id_document") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("_article_name") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="countLabel" runat="server" Text='<%# Eval("_article_count") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="priceLabel" runat="server" Text='<%# Eval("_article_price") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="sumLabel" runat="server" Text='<%# Eval("_article_sum") %>' />
                                                                </td>
                                                                <td>
                                                                    <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                                                                </td>
                                                                <td>
                                                                    <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                                                                </td>
                                                            </tr>
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            <td id="article_ID" runat="server">
                                                                <asp:Label ID="id_articleLabel" runat="server" Text='<%# Eval("_id") %>' />
                                                            </td>
                                                            <td id="document_ID" runat="server">
                                                                <asp:Label ID="id_documentLabel" runat="server" Text='<%# Eval("_id_document") %>' />
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="tb_name" runat="server" ValidationGroup="edit" Text='<% #Bind("_article_name")%>'></asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="nameValidator" runat="server" ControlToValidate="tb_name" ErrorMessage="<div>Article name cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="edit_art"></asp:RequiredFieldValidator>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="tb_count" runat="server" ValidationGroup="edit" Text='<% #Bind("_article_count")%>'></asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="countValidator" runat="server" ControlToValidate="tb_count" ErrorMessage="<div>Article count cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="edit_art"></asp:RequiredFieldValidator>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="tb_price" runat="server" ValidationGroup="edit" Text='<% #Bind("_article_price")%>'></asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="priceValidator" runat="server" ControlToValidate="tb_price" ErrorMessage="<div>Article price cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="edit_art"></asp:RequiredFieldValidator>
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="lblsum" runat="server" Text='<% #Bind("_article_sum")%>'></asp:Label>
                                                            </td>
                                                            <td>                    
                                                                <asp:LinkButton ID="lnkUpdate" runat="server" CommandName="Update_article" ValidationGroup="edit_art">Update</asp:LinkButton>
                                                            </td>
                                                            <td>
                                                                <asp:LinkButton ID="lnkCancel" runat="server" CommandName="Cancel_article">Cancel</asp:LinkButton>                    
                                                            </td>
                                                        </EditItemTemplate>
                                                        <InsertItemTemplate>
                                                        <tr id="Tr1" runat="server">
                                                            <td>
                                                                <asp:TextBox ID="tb_name_insert" runat="server" ValidationGroup="add" Text='<% #Eval("_article_name")%>'>Name</asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="nameValidator" runat="server" ControlToValidate="tb_name_insert" ErrorMessage="<div>Article name cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_article"></asp:RequiredFieldValidator>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="tb_count_insert" runat="server" ValidationGroup="add" Text='<% #Eval("_article_count")%>'>0</asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="countValidator" runat="server" ControlToValidate="tb_count_insert" ErrorMessage="<div>Article count cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_article"></asp:RequiredFieldValidator>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="tb_price_insert" runat="server" ValidationGroup="add" Text='<% #Eval("_article_price")%>'>0</asp:TextBox>
                                                                <asp:RequiredFieldValidator ID="priceValidator" runat="server" ControlToValidate="tb_price_insert" ErrorMessage="<div>Article price cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_article"></asp:RequiredFieldValidator>
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="lblsum" runat="server" Text='<% #Eval("_article_sum")%>'></asp:Label>
                                                            </td>
                                                            <td colspan="2" style="text-align:center;">
                                                               <asp:LinkButton ID="lnkInsert" runat="server" CommandName="Insert_article" ValidationGroup="add_article">Insert</asp:LinkButton>                    
                                                            </td>
                                                        </tr>
                                                        </InsertItemTemplate>
                                                    </asp:ListView>
                                                    <div style="text-align:center; padding:10px;">
                                                        <asp:Label ID="modal_message_article" runat="server" Text="&nbsp" style="font-size:0.9em; font-weight:bold;"/>
                                                    </div>
                                                   </div>
                                                </ContentTemplate>
                                            </ajaxToolkit:TabPanel>
                                        </ajaxToolkit:TabContainer>
                                          </ContentTemplate>
                                       </asp:UpdatePanel>
                                    </div>
                                </div>
                                <asp:hiddenfield id="HiddenField9" runat="server" />
                                <ajaxToolkit:ModalPopupExtender ID="Modal_add_document" runat="server" Drag="true" PopupDragHandleControlID="Add_document" TargetControlID="HiddenField9" PopupControlID="Add_document" CancelControlID="bt_cancel" BackgroundCssClass="modalPopupBackground" />
                            </asp:Panel>
                    <div class="message-notice" id="message2" runat="server">
                        <div class="image">
                            <img height="32" alt="Notice" src="Images/notice.png"/>
                        </div>
                        <div class="text">
                            <h4 id="message2Text" runat="server" > You have no documents!</h4>
                        </div>
                    </div> 
                    </ContentTemplate>
                    </asp:UpdatePanel>   
                    <div style="padding-top:15px;">
                        <asp:Button id="Button2" runat="server" onclick="bt_add_new_document_Click" Text="Add new document" CssClass="GreenBtn"/>
                        <asp:Button id="bt_delete_my_selected_invoices" runat="server" onclick="bt_delete_my_selected_invoices_Click" Text="Delete selected documents" CssClass="BlueBtn"/>
                    </div>               
                </div>
            </div>
            <div class="box">
                <div class="title">
                    <h6>
                        <asp:label runat="server" text="My users documents"></asp:label>
                    </h6>
                </div>
                <div class="lists">
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">                        
                    <ContentTemplate>
                    <asp:ListView ID="My_users_documents_list" runat="server" OnPagePropertiesChanging="My_users_documents_list_PagePropertiesChanging"
                        OnItemDataBound="My_users_documents_list_ItemDataBound" OnItemCommand="My_users_documents_list_ItemCommand">
                        <LayoutTemplate>
                            <table id="gradient-style" class="tab">
                                <thead>
                                    <tr>
                                        <th>Number
                                            <asp:ImageButton ID="a" CommandName="doc_num_users" ImageUrl="~/Images/asc.png" runat="server" />
                                            <asp:ImageButton ID="b" CommandName="doc_num_users_desc" ImageUrl="~/Images/desc.png" runat="server" />
                                        </th>
                                        <th>Date
                                            <asp:ImageButton ID="c" CommandName="doc_date_user" ImageUrl="~/Images/asc.png" runat="server" />
                                            <asp:ImageButton ID="d" CommandName="doc_date_user_desc" ImageUrl="~/Images/desc.png" runat="server" />
                                        </th>
                                        <th>Payment date</th>
                                        <th>User</th>
                                        <th>Company</th>
                                        <th>Client</th>
                                        <th>Type</th>
                                        <th>Payment type</th>
                                        <th>Status</th>
                                    </tr>
                                </thead>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                                <tfoot>
                                    <tr>
                                        <th style="text-align: right" colspan="9">
                                            <asp:DataPager ID="My_users_documents_list_Page" runat="server" PagedControlID="My_users_documents_list" PageSize="5">
                                                <Fields>
                                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                    <asp:NumericPagerField />
                                                    <asp:TemplatePagerField>
                                                        <PagerTemplate>
                                                            Page
                                                            <asp:Label runat="server" ID="labelCurrentPage1" Text="  <%  #  Container.TotalRowCount > 0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0  %>  " />
                                                            /
                                                            <asp:Label runat="server" ID="labelTotalPages1" Text="  <%  #   Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize)  %>  " />
                                                        </PagerTemplate>
                                                    </asp:TemplatePagerField>
                                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                </Fields>
                                            </asp:DataPager>
                                        </th>
                                    </tr>
                                </tfoot>
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr>
                                <td id="docID" runat="server">
                                    <asp:Label ID="doc_IDLabel" runat="server" Text='<%# Eval("id") %>' />
                                </td>
                                <td>
                                    <asp:LinkButton ID="document_numberLabel" runat="server" Text='<%# Eval("document_number") %>' CommandName="Invoice" />
                                </td>
                                <td>
                                    <asp:Label ID="document_dateLabel" runat="server" Text='<%# Eval("document_date","{0:yyyy.MM.dd}") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="document_payment_dateLabel" runat="server" Text='<%# Eval("document_payment_date","{0:yyyy.MM.dd}") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="issued_by_userLabel" runat="server" Text='<%# Eval("issued_by_user") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="id_company_issued_byLabel" runat="server" Text='<%# Eval("company_issued_by") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="id_company_issued_toLabel" runat="server" Text='<%# Eval("client_issued_to") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="id_document_typeLabel" runat="server" Text='<%# Eval("document_type") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="id_payment_typeLabel" runat="server" Text='<%# Eval("payment_type") %>' />
                                </td>
                                <td id="idL" runat="server">
                                    <asp:Label ID="id_issued_userLabel" runat="server" Text='<%# Eval("id_issued_by_user") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="status" runat="server" Text='<%# Eval("status") %>' />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>                    
                    </ContentTemplate>
                    </asp:UpdatePanel>
                    <br />
                    <div class="message-notice" id="message" runat="server">
                        <div class="image">
                            <img height="32" alt="Notice" src="Images/notice.png"/>
                        </div>
                        <div class="text">
                            <h4>Your users have no documents!</h4>
                        </div>
                    </div>
                </div>
            </div>
        </asp:panel>

        <script type="text/javascript">
            function OnCancel() {
                document.getElementById('<%=bt_Cancel.ClientID%>').click();
            }
            function OnCancelDelete() {
                document.getElementById('<%=bt_Cancel_delete.ClientID%>').click();
            }
            function setBodyHeightToContentHeight() {
                document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px";
            }
            setBodyHeightToContentHeight();
            $addHandler(window, "resize", setBodyHeightToContentHeight);
        </script>
    </div>
</asp:content>
